%ejemplos


%Ej1
valor(X).
valor(1).
valor(5).

%Ej2
dim([   [1,2,3],
        [1,2,3]], F, C).
F = 3,
C = 2.

dim([   [1,3],
        [1,3]], F, C).
F = 2,
C = 2.

dim([   [1,_],
        [_,3]], F, C).
F = 2,
C = 2.


dim([   [1,A],
        [B,3]], F, C).
F = 2,
C = 2.

%Ej3

pos([   [1,A],
        [B,3]], F, C).
F = 1,
C = 1 ;
F = 2,
C = 1 ;
F = 1,
C = 2 ;
F = 2,
C = 2.

pos(   [[1,2,3],
        [1,2,3]], F, C).
F = 1,
C = 1 ;
F = 2,
C = 1 ;
F = 3,
C = 1 ;
F = 1,
C = 2 ;
F = 2,
C = 2 ;
F = 3,
C = 2.


%Ej4
?- nonvars([1,A,B,3], NV).
NV = [1, 3].

?- nonvars([1,A,4,3], NV).
NV = [1, 4, 3].

?- nonvars([1,A,4,C,3], NV).
NV = [1, 4, 3].

?- nonvars([], NV).
NV = [].

%Ej5

?- cant_minas([1,mina,B,3], NM).
NM = 1.

?- cant_minas([1,mina,mina,3], NM).
NM = 2.

?- cant_minas([], NM).
NM = 0.

?- cant_minas([1,_,A,3], NM).
NM = 0.



%Ej6
?- vecinos([[1,2,3],
            [4,5,6],
            [7,8,9]], 1, 1, L).
L = [2, 4, 5].

?- vecinos([[1,2,3],
            [4,5,6],
            [7,8,9]], 1, 2, L).
            
L = [1, 2, 5, 7, 8].

?- vecinos([[1,2,3],
            [4,5,6],
            [7,8,9]], 2, 2, L).
L = [1, 2, 3, 4, 6, 7, 8, 9].


%Ej7
?- consistente([[0,0,0],
                [0,0,0],
                [0,0,A]], 2, 2).
true.

?- consistente([[0,0,0],
                [0,0,0],
                [0,0,0]], 2, 2).
true.

?- consistente([[0,0,0],
                [0,mina,0],
                [0,0,0]], 2, 2).
true.

?- consistente([[0,0,0],
                [0,0,0],
                [0,0,0]], 2, 2).
true.

?- consistente([[0,0,0],
                [0,1,0],
                [0,0,0]], 2, 2).
false.

?- consistente([[mina   ,1,0],
                [1      ,1,0],
                [1      ,0,0]], 1, 1).
true.


%Ej8

?- consistente([ [mina  ,1,0],
                 [1     ,1,0],
                 [1     ,0,0]]).
false.

?- consistente([    [mina,1,0],
                    [1   ,1,0],
                    [1   ,1,0]]).
false.

?- consistente([[mina,1,0],
                [1   ,1,0],
                [0   ,0,0]]).
true.              

%Ej9
completarA([[mina,C,0],
                [A,B,0],
                [0,0,0]]).
C = 1,
A = 1,
B = 1 ;
false.

?- completarA([[1,   C,D],               [A,mina,E],               [H,   G,1]]).
C = 1, D = 1, A = 1, E = 1, H = 1, G = 1 ;
C = 1, D = 1, A = 2, E = 1, H = mina, G = 2 ;
C = 2, D = mina, A = 1, E = 2, H = 1, G = 1 ;
C = 2, D = mina, A = 2, E = 2, H = mina, G = 2 ;
false.

completarA([[1,C],
                [A,mina],
                [H,1]]).
C = 1,
A = 1,
H = 1 ;
false.

completarA([[1,C],
                [2,mina],
                [H,1]]).
false.



